<template>
	<mg-popup v-model="showp" z-index="2000">
		<view class="bf">
			<view class="f-bt hlb">
				<view @click="showp=false" class="p253 c9">取消</view>
				<view @click="qdxz" class="p253 c0">确定</view>
			</view>
			<view class="o-y-s" style="max-height: 600rpx;">
				<mg-radio v-if="type==1" rtype="2" v-model="radiov" :arr='arr' :color='color'></mg-radio>
				<mg-checkbox v-else rtype="2" v-model="radiov" :arr='arr' :color='color'></mg-checkbox>
			</view>
		</view>
	</mg-popup>
</template>

<script>
	import {
		mapState,
		mapActions
	} from 'vuex'
	import mgPopup from '@/components/common/popup.vue'
	import mgRadio from '@/components/form/mg-radio.vue'
	import mgCheckbox from "@/components/form/mg-checkbox.vue"
	export default {
		name: 'mg-as',
		components: {
			mgPopup,
			mgRadio,
			mgCheckbox,
		},
		props: {
			show: {
				type: Boolean,
				default: false
			},
			value: String | Number,
			arr: {
				type: Array,
				default: []
			},
			type: {
				type: String,
				default: '1'
			},
			color: {
				type: String,
				default: ''
			},
			dval: String | Number,
		},
		data() {
			return {
				radiov: '',
			}
		},
		computed: {
			showp: {
				get() {
					return this.show;
				},
				set(newVal) {
					this.$emit('update:show', newVal)
				}
			},
			// radiov: {
			// 	get() {
			// 		return this.value;
			// 	},
			// 	set(newVal) {
			// 		this.$emit("input", newVal)
			// 	}
			// },
		},
		watch: {
			dval: {
				handler(newVal) {
					this.radiov = newVal
					console.log(newVal)
				},
				immediate: true,
			},
		},
		methods: {
			qdxz() {
				this.showp = false
				if (this.type == 1) {
					if (this.radiov !== '') {
						this.$emit("confirm", {
							v: this.radiov,
							i: this.arr.findIndex(v => v.value == this.radiov)
						})
					}
				} else {
					this.$emit("confirm", {
						v: this.radiov,
					})
				}
				console.log(this.radiov)
			}
		},
	}
</script>

<style scoped lang="scss">
</style>
